
package com.zsrt.day20170406.homework;

import java.util.Scanner;

/**
 * 打印空心菱形
 * @author jmj
 * @date 2017年4月6日
 * @time 下午6:36:46
 */
public class Printlingxing {
	public static void main(String[] args) {
		System.out.println("请输入你想打印的行数:");
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		in.close();
		int n =h/2;
		lingXing(n);
	}
	
	public  static void lingXing(int n){
		//打印菱形的最上面一个星
		for(int i =1;i<=n;i++){
			System.out.print(" ");
		}
	    System.out.println("*");
	    for(int hang=1;hang<=n;hang++){
		    for(int kg=1;kg<=n-hang;kg++){
			    System.out.print(" ");
		    }
		    System.out.print("*");
	        for(int kg=1;kg<=hang*2-1;kg++){
	    	    System.out.print(" ");
	        }
	        System.out.print("*");
	        System.out.println(); 
	    }
	    //打印菱形的下半部分
	    for(int hang=1;hang<=n-1;hang++){
		    for(int kg=1;kg<=hang;kg++){
			    System.out.print(" ");
		    }
		    System.out.print("*");
	        for(int kg=1;kg<=(n-hang)*2-1;kg++){
	    	    System.out.print(" ");
	        }
	        System.out.print("*");
	        System.out.println();
	    }
	    //打印菱形的最下面一个星
	    for(int i =1;i<=n;i++){
		    System.out.print(" ");
	    }
	    System.out.println("*");
	}
}
